   package com.javalong.affairs.module.task.activity;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.widget.FrameLayout;

import com.javalong.affairs.R;
import com.javalong.affairs.base.activity.UIHandlerActivity;
import com.javalong.affairs.base.common.ServiceLocator;
import com.javalong.affairs.base.common.UIHandler;
import com.javalong.affairs.base.constant.BundleKey;
import com.javalong.affairs.base.constant.RequestCode;
import com.javalong.affairs.module.task.fragment.TaskSearchFragment;
import com.javalong.affairs.base.model.Dept;
import com.javalong.affairs.base.ui.TopTitle;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ContentView;
import com.lidroid.xutils.view.annotation.ViewInject;

@ContentView(R.layout.activity_tasksearch)
public class TaskSearchActivity extends UIHandlerActivity {
	@ViewInject(R.id.ui_toptitle)
	private TopTitle topTitle;
	private FrameLayout fl_content;
	private Date nowDate = new Date();
	private int currType = 0;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		ViewUtils.inject(this);
		topTitle.setOnLeftDrawableClick(this);
		FragmentTransaction ft =getSupportFragmentManager().beginTransaction();
		Fragment f = new TaskSearchFragment();
		ft.add(R.id.fl_content, f);
		ft.commit();
	}

	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		super.onActivityResult(requestCode, resultCode, data);
		if (resultCode == RESULT_OK) {
			switch (requestCode) {
			case RequestCode.DEPTLIST:
				List<Dept> deptList = (List<Dept>) data
						.getSerializableExtra(BundleKey.DEPTLIST);
				Bundle bundle = new Bundle();
				bundle.putSerializable(BundleKey.DEPTLIST,
						(Serializable) deptList);
				UIHandler uiHandler = ServiceLocator.GetInstance().getInstance(
						UIHandler.class);
				uiHandler.postCallback(R.string.event_add_dept, bundle);
				break;
			}
		}
	}
}
